﻿using System;
using System.Collections.Generic;

using NUnit.Framework;

using VidoopSecure;
using VidoopSecureExtensionMethods;

 namespace TestVidoopSecure
{
    [TestFixture]
    public class TestVoicePtl : BaseTest
    {
        [TestFixtureSetUp]
        public override void SetUp()
        {
            base.SetUp();
        }

        [TestFixtureTearDown]
        public override void TearDown()
        {
            base.TearDown();
        }


        [Test]
        public void Test_GetService()
        {
            Service voiceptlService = Manager.GetService(
                "voiceptl", CurrentSite);
            Assert.IsNotNull(voiceptlService);
        }

        [Test]
        public void Test_Newvoiceptl()
        {
            VoicePtlService service = (VoicePtlService)Manager.GetService(
                "voiceptl", CurrentSite);
            Assert.IsNotNull(service);

            Random rand = new Random(DateTime.Now.Millisecond);
            string userId = RandomString(8,false);
            string phone = Settings.PhoneNumber;
            string ptl = RandomNumber(1000, 9999).ToString();
            VoicePtl voiceptl = service.NewVoicePtl(userId, phone);
            Assert.IsNotNull(voiceptl);

            Assert.AreEqual(phone, voiceptl.Phone);
            Assert.AreEqual("pending", voiceptl.SendStatus);
            Assert.AreEqual("pending", voiceptl.AuthenticationStatus);

            // Test the GET of the transaction status
            VoicePtl voiceptl2 = service.GetVoicePtl(voiceptl.Id);
            Assert.IsNotNull(voiceptl2);

            Assert.AreEqual(phone, voiceptl2.Phone);
            //Result of this next test depends on whether you answered call I believe.
            //Assert.IsTrue("pending" == voiceptl2.SendStatus ||
            //              "success" == voiceptl2.SendStatus);
            Assert.AreEqual("pending", voiceptl2.AuthenticationStatus);
       }
    }
}
